<?php include('./templete/public/head.php') ?>
<body>

<!--搜索-->
<div class="comm-search">
    <div class="search-input">
        <i class="iconfont icon-sousuo"></i>
        <input type="text" name="" id="title" value="<?php echo input('title') ?>" placeholder="请输入您要搜索的攻略"
               onchange="search()"/>
    </div>
</div>
<!--搜索标签-->
<div class="search-tag">
    <div class="tag1">
        <a href="<?php echo url('index', ['type' => 1]) ?>" class="<?php if ($type == 1) { ?>active <?php } ?>">所有分享</a>
        <a href="<?php echo url('index', ['type' => 2]) ?>" class="<?php if ($type == 2) { ?>active <?php } ?>">我的分享</a>
        <a href="<?php echo url('insert') ?>">发布分享</a>
    </div>
</div>
<hr class="bgcolor"/>
<!--所有攻略-->
<div class="index-main all-strategy">
    <div class="main-content strategy-content">
        <div class="c-list">
        </div>
    </div>
</div>
</div>
</div>
</body>
</html>
<script>
    function get_list(page){
        var type = '<?php echo $type?>';
        //var page =1;
        var title = $('#title').val();
        $.ajax({
            url:'<?php echo url("get_list")?>',
            data:{
                title:title,
                type:type,
                page:page,
            },
            success:function (data) {
                $(".c-list").append(data);
            }

        })
    }
    get_list(1);
    $(function () {
        var page = 2;
        var load_flag = true;
        $(window).scroll(function () {
            var totalheight = parseFloat($(window).height()) + parseFloat($(window).scrollTop());
            var documentheight = parseFloat($(document).height());
            var title = $('#title').val();
            if (documentheight - totalheight <= 200) {
                $("#loadmore").show();
                if (load_flag) {
                    load_flag = !load_flag;
                    get_list(page);
                    load_flag=!load_flag;
                    page++;
                }

            }
        });
    });

    function search() {
        var title = $('#title').val();
        window.location.href = "/index/life/index.html?title=" + title + '&type=' +'<?php echo $type?>';
    }
</script>